package com.group.transaction.controller;


import com.alibaba.fastjson.JSONObject;
import com.group.transaction.aspect.InMethod;
import com.group.transaction.domain.Role;
import com.group.transaction.domain.User;
import com.group.transaction.model.ResultJson;
import com.group.transaction.service.role.RoleService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 角色相关的接口
 */
@RestController
@RequestMapping("/role")
@Slf4j
@Data
public class RoleController {
    @Resource
    private RoleService roleService;

    /**
     * 添加角色
     * @param role
     * @return
     */
    @PostMapping("/addRole")
    @InMethod(apiName = "添加角色")
    public JSONObject addRole (@RequestBody Role role) {
        return roleService.addRole(role);
    }
    /**
     * 编辑角色
     * @param role
     * @return
     */
    @InMethod(apiName = "编辑角色")
    @PostMapping("/compileRole")
    public JSONObject compileRole (@RequestBody Role role) {
        return roleService.compileRole(role);
    }
    /**
     * 删除角色
     * @param role
     * @return
     */
    @InMethod(apiName = "删除角色")
    @GetMapping("/deleteRole")
    public JSONObject deleteRole (Role role) {
        return roleService.deleteRole(role);
    }
    /**
     * 查询角色
     * @param role
     * @return
     */
    @GetMapping("/queryRoleData")
    @InMethod(apiName = "查询角色")
    public JSONObject queryRoleData ( Role role) {
        return roleService.queryRoleData(role);
    }
}
